﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Manageloginaspx : System.Web.UI.Page
{
    DBClass dbObj = new DBClass();

    protected void Page_Load(object sender, EventArgs e)
    {
        txtName.Focus();
    }

    protected void ibtnLogin_Click(object sender, ImageClickEventArgs e)   //实现登录功能
    {
        if (txtName.Text.Trim() == "" || txtPwd.Text.Trim() == "")   //若用户名或密码框的内容为空，则弹出
        {
            Response.Write("<script language=javascript>alert('用户名和密码不能为空!')</script>");
        }
        else 
        {
            string strRights = ddlRights.SelectedValue.ToString();
            bool flag;
            if (strRights == "超级管理员")
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
            string strSql = "select * from tb_Admin where AdminName='" + txtName.Text.Trim() + "'and AdminPwd='" + txtPwd.Text.Trim() + "'and Class=flag";
            DataTable dt = dbObj.GetDataSet(strSql, "tb_Admin");
            if (dt.Rows.Count > 0)
            {
                Session["Name"] = txtName;
                Session["Class"] = flag;
                Response.Redirect("");
            }
            else
            {
                Response.Write("<script language=javascript>alert('你输入的用户名或密码有误，请重新输入！')</script>");
            }
        }

        
    }
}